<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>垃圾分类查询</title>
<link href="<%=path%>/static/usercss/css/all.css?39230239j" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.js"></script>
<!--[if IE]>
<script>
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
</script>
<![endif]-->
</head>
<body>
<jsp:include page="/WEB-INF/web/includ/header.jsp"></jsp:include>
<section>
<div class="wrap">
<div class="section">
    <article id="datalist">
      <nav>
        <div class="seach">
       <form action="<%=path%>/web/userinfo/addData" method="post">
        <input name="classification" type="text"  aria-label="输入废弃物名称" placeholder="输入废弃物名称" autocapitalize="off">
    		<a href="javascript:void(0);" id="piPei">匹配分类</a>
    	</form>
        </div>
       <!--  <div class="msg">
          推荐分类 <a href="#">创建新的分类及名称</a>
        </div> -->
        <div id="breadcrumb">
 
      </div>
    </nav>
 
    <c:if test="${requestScope.theData.content==null }" var = "kkk">
    <div id="title">
      <h1>添加数据</h1>
      <label>分类名称</label>
      <span><a href="add-dade.html">添加数据</a></span>
    </div>
    <datalist id="dataList">
		 	<jsp:include page="/WEB-INF/web/includ/dataList.jsp"></jsp:include>
		 	</datalist>
		 	</c:if>
		 	
		 	
		 	<c:if test="${!kkk }">
		 	<div id="title">
      <h1>更改数据</h1>
      <label>分类名称</label>
      <span><a href="add-dade.html">添加数据</a></span>
    </div>
    <datalist id="dataList">
		 	<jsp:include page="/WEB-INF/web/includ/changeData.jsp"></jsp:include>
		 	</datalist>
		 	</c:if>
		 
  </article>
  <jsp:include page="/WEB-INF/web/includ/aside.jsp"></jsp:include>
</div>
</div>
</section>
<jsp:include page="/WEB-INF/web/includ/footer.jsp"></jsp:include>
</body>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/messages_zh.js"></script> 

<script type="text/javascript">
	var msg ="${param.msg}";

	if(msg=='succ'){
		
		layer.alert("提交成功");	
	}
	if(msg=='Num'){
		
		layer.alert("数量格式不对！");
	}
</script>
<script type="text/javascript">
	function accept(id) {
			$.ajax({
				type:'post',
				url:'<%=path%>/web/userinfo/accept',
				data:{id:id},
				success:function(mes){
					$("#dataList").empty();
					$("#dataList").append(mes);
				}
			})
	}
	
	$(function() {
		$("#piPei").click(function() {
				var seachData = $(this).prev().val();		
				$.ajax({
					type:'post',
					url:'<%=path%>/web/userinfo/seachData',
					data:{seachData:seachData},
					success:function(mes){
						$("#breadcrumb").empty();
						 var json = eval(mes); //数组    
						 var i = 0;
             $.each(json, function (index, item) {
                 //循环获取数据  
                 if(i>2){
                	 return;
                 }
                 var id = json[index].id;                
									
                 var str1 ="<ul><li><a href=\"javascript:void(0);\">"+json[index].secondtype.firsttype.title+"</a><span>&gt;</span></li>";
                 var str2 = "<li><a href=\"javascript:void(0);\">"+json[index].secondtype.title+"</a><span>&gt;</span></li>"
                 var str3 = "<li><a href=\"javascript:void(0);\">"+json[index].name+"</a></li><li onclick=\"accept("+json[index].id+")\"><a  href=\"javascript:void(0);\">采用</a></li></ul>"    
                 var str = str1+str2+str3;    
                 var rubbish = $(str); 
                 
                 $("#breadcrumb").append(rubbish);
                 i++;
              });
             $("#breadcrumb").append("<ul><li><a>没有你想要的垃圾？请</a><a style=\"color:blue;\" href=\"<%=path%>/web/rubbish/addRubbish\">添加</a></li></ul>");
					}
				});

		});
	});
	

</script>
</html>
